#!/bin/bash

declare -a php_major_version=$(php -v | head -n 1 | cut -c 5)

if [ $php_major_version == "8" ]; then
    declare -a laravel=("10.*")
    declare -a testbench=("8.*")
fi

for i in "${!laravel[@]}"
do
   echo "${laravel[i]}"
   echo "${testbench[i]}"

   composer remove --quiet illuminate/support orchestra/testbench
   composer require --no-update --no-interaction --quiet "illuminate/support:${laravel[i]}" "orchestra/testbench:${testbench[i]}"
   composer update --prefer-dist --no-interaction --quiet --prefer-lowest
   ./vendor/bin/phpunit
done


## composer remove --quiet illuminate/support orchestra/testbench \
## && composer require --no-update --no-interaction --quiet "illuminate/support:7" "orchestra/testbench:5" \
## && composer update --prefer-lowest --prefer-dist --no-interaction \
## && ./vendor/bin/phpunit